
const router = require('koa-router')();
const tool = require('../util/tool')
const tokenHelper = require('../util/token-helper')


router.post('/',async (ctx)=>{
  const token = tool.getTokenFromCtx(ctx);
  if(token){
    let user = tokenHelper.decodeToken(ctx);
    let newToken = tokenHelper.createToken(user);
    //console.log('要返回的user',user)
    ctx.body = {userId:user.userId,userName:user.userName,rank:user.rank,token:newToken,};
  }
})


module.exports = router;
